package com.qk.management.config;


import com.qk.entity.User;

/**
 * ThreadLocal为每个线程单独提供一份存储空间
 * 将ThreadLocal进行封装，便于代码的维护和迭代
 */
public class UserThreadLocal {
    /**
     * 存储用户信息
     */
    private static final ThreadLocal<User> userThread = new ThreadLocal<>();
 
    public static void set(User user) {
        userThread.set(user);
    }
 
    public static User getUser() {
        return userThread.get();
    }
 
    public static void remove() {
        userThread.remove();
    }
}